package zl.io;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

public class IODemo04
{
	public static void main(String[] args)
	{
		File file = new File("C:" + File.separator + "Test.txt");
		OutputStream out = null;
		Writer writer = null;
		try
		{
			if(!true)
			{
				out = new FileOutputStream(file,true);
				String str = "\r\nHello World!!!";
				byte[] b = str.getBytes();
				for(int i = 0; i < b.length; i++)
				{
					out.write(b[i]);
				}
			}
			else
			{
				writer = new FileWriter(file,true);
				String str = "\r\nHello World!!!";
				writer.write(str);
				writer.flush();  //刷新缓存
			}
		}
		catch (FileNotFoundException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
}